<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Inserts</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="Smarty 3 Manual">
<link rel="up" href="plugins.html" title="Chapter 18. Extending Smarty With Plugins">
<link rel="prev" href="plugins.resources.html" title="Resources">
<link rel="next" href="bc.html" title="Chapter 19. SmartyBC - Backwards Compatibility Wrapper">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Inserts</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="plugins.resources.html">Prev</a> </td>
<th width="60%" align="center">Chapter 18. Extending Smarty With Plugins</th>
<td width="20%" align="right"> <a accesskey="n" href="bc.html">Next</a>
</td>
</tr>
</table>
<hr>
</div>
<div class="sect1" title="Inserts">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="plugins.inserts"></a>Inserts</h2></div></div></div>
<p>
     Insert plugins are used to implement functions that are invoked by
     <a class="link" href="language.function.insert.html" title="{insert}"><code class="varname">{insert}</code></a>
     tags in the template.
    </p>
<div class="funcsynopsis">
<table border="0" summary="Function synopsis" cellspacing="0" cellpadding="0" class="funcprototype-table">
<tr>
<td><code class="funcdef">string <b class="fsfunc">smarty_insert_name</b>(</code></td>
<td>
<var class="pdparam">$params</var>, </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td>
<var class="pdparam">$template</var><code>)</code>;</td>
<td> </td>
</tr>
</table>
<div class="paramdef-list">
<code>array <var class="pdparam">$params</var></code>;<br><code>object <var class="pdparam">$template</var></code>;</div>
<div class="funcprototype-spacer"> </div>
</div>
<p>
     The first parameter to the function is an associative array of
     attributes passed to the insert.
    </p>
<p>
     The insert function is supposed to return the result which will be
     substituted in place of the <code class="varname">{insert}</code> tag in the
     template.
    </p>
<div class="example">
<a name="id466068"></a><p class="title"><b>Example 18.11. insert plugin</b></p>
<div class="example-contents"><pre class="programlisting">

&lt;?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     insert.time.php
 * Type:     time
 * Name:     time
 * Purpose:  Inserts current date/time according to format
 * -------------------------------------------------------------
 */
function smarty_insert_time($params, Smarty_Internal_Template $template)
{
    if (empty($params['format'])) {
        trigger_error("insert time: missing 'format' parameter");
        return;
    }
    return strftime($params['format']);
}
?&gt;

     </pre></div>
</div>
<br class="example-break">
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="plugins.resources.html">Prev</a> </td>
<td width="20%" align="center"><a accesskey="u" href="plugins.html">Up</a></td>
<td width="40%" align="right"> <a accesskey="n" href="bc.html">Next</a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Resources </td>
<td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td>
<td width="40%" align="right" valign="top"> Chapter 19. SmartyBC - Backwards Compatibility Wrapper</td>
</tr>
</table>
</div>
</body>
</html>
